#include <queue>
#include <iostream>
using namespace std;

class RecentCounter{
    int windowSize;
    queue<int> times;
public:
    RecentCounter(int timeRange){
        this->windowSize = timeRange;
    }
    int ping(int time){
        times.push(time);
        while(times.front() + windowSize < time){
            times.pop();
        }
        return times.size();
    }
};

int main(){
    RecentCounter counter(3000);
    cout<<counter.ping(1)<<endl;
    cout<<counter.ping(10)<<endl;
    cout<<counter.ping(3001)<<endl;
    cout<<counter.ping(3002)<<endl;
    return 0;
}